﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.Security.Application;
using ThreeDPrinting.ORM;
using System.Web.Mail;
using SMTP.Utilities;
using ThreeDPrinting.Utilities;
using System.Web.Resources;

namespace ThreeDPrinting.Pages.Register
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnCreateAccount_Click(object sender, EventArgs e)
        {
            using (DBEntities entities = new DBEntities())
            {
                string plainText = txtPassword.Text;
                string passPhrase = "Pas5pr@se";
                string saltValue = "s@ltValue";
                string hashAlgorithm = "SHA1";
                int passwordIterations = 2;
                string initVector = "@1B2c3D4e5F6g7H8";
                int keySize = 256;
                string EncryptedPassword = RijndaelSimple.Encrypt(plainText, passPhrase, saltValue, hashAlgorithm, passwordIterations, initVector, keySize);
                //Insert a Record
                //===================================
                //Create the member mem object
                tblmember mem = new tblmember();
                //fill the object with data
                mem.memberUserName = txtUserName.Text;
                mem.memberPassword = txtPassword.Text;
                mem.memberEmail = txtEmail.Text;
                //Call the method to add the object to the table
                entities.tblmembers.Add(mem);
                //Save the changes to the DB
                entities.SaveChanges();
                string username = "Username:" + txtUserName.Text;
                string password = "Password:" + txtPassword.Text;
                string email = txtEmail.Text;
                MailHelper.SendMailMessage("account@digireal.com", email, null, null, "Digi-Real Account Information", username + "  " + password);
                //Response.Write("<script>alert('Your Account Information has been sent to your registered E-mail')</script>");
                Response.Redirect("~/Pages/Register/Confirm.aspx");
            }
        }
    }
}